<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%channel}}".
 *
 * @property string $id
 * @property string $title
 * @property string $url
 * @property integer $sort
 * @property integer $create_time
 * @property integer $status
 */
class Channel extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%channel}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title', 'url'], 'required'],
            [['sort', 'create_time', 'status'], 'integer'],
            [['title', 'url'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '导航名称',
            'url' => '导航地址',
            'sort' => '排序',
            'create_time' => '创建时间',
            'status' => '状态',
        ];
    }

	/**
	 * 新增菜单的方法
	 */
	public function add(){
		$this->sort = intval($this->sort);
		$this->create_time = time();

		return $this->insert();
	}
}
